package com.woniuxy.shiro.controller;

import com.woniuxy.entity.RbacManager;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.shiro.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description: LoginController <br>
 * date: 2021/12/6 12:12 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */
@RestController
@RequestMapping("/auth")
public class LoginController {
    @Autowired
    LoginService loginService;
    //登录操作，直接去匹配数据库即可，不用自定义一个域
    @RequestMapping("/login")
    public ResponseEntity<RbacManager> login(@RequestBody RbacManager rbacManager){
        RbacManager rbacManagers = loginService.login(rbacManager.getAccount(), rbacManager.getPassword());
       // System.out.println("rbacManagers"+rbacManagers);
        if(rbacManagers==null){
            //没有匹配成功
            return new ResponseEntity<>(401,"登录失败",null);
        }else {
            //执行成功的业务
            return new ResponseEntity<>(200,"登录成功",rbacManagers);
        }

    }
}
